import {Request} from "../request"

const Banner = () => Request({ //获取启动页,首页轮播图
  url: "/banner/list",
  method: "get"
})

const shopData = () => Request({ //获取九宫格数据
  url: "/shop/goods/category/all",
  method: "get"
})

const infoNoticeApi = () => Request({ //获取优惠
  url: "/notice/list",
  method: "POST"
})

const goodsListApi = () => Request({ //获取限时秒杀
  url: "/shop/goods/list",
  method: 'POST'
})

const shopList = (data) => Request({ //获取商品信息
  url: `/shop/goods/list/v2?pageSize=${data.pageSize}&page=${data.page}`,
  method: "post",
})
const shopList1 = (data) => Request({ //获取商品信息
  url: `/shop/goods/list/v2`,
  method: "post",
})
const detail = (data) => Request({ //获取商品详情
  url: `/shop/goods/detail`,
  method: "get",
  data
})
const favGoodsCheck = (data) => Request({ //检查是否收藏
  url: `/shop/goods/fav/check`,
  method: "get",
  data
})
const addGoodsCheck = (data) => Request({ //添加收藏
  url: `/shop/goods/fav/add`,
  method: "post",
  data
})
const delGoodsCheck = (data) => Request({ //删除收藏
  url: `/shop/goods/fav/delete`,
  method: "post",
  data
})
const  cartList= (data) => Request({ //读取购物车数据
  url: `/shopping-cart/info`,
  method: "get",
  data
})
const  addCart= (data) => Request({ //添加购物车
  url: `/shopping-cart/add`,
  method: "post",
  data
})
const  emptyCart= (data) => Request({ //清空购物车
  url: `/shopping-cart/empty`,
  method: "post",
  data
})
const  removeCart= (data) => Request({ //移除购物车的某条数据
  url: `/shopping-cart/remove`,
  method: "post",
  data
})
const  editNum= (data) => Request({ //修改某条购物车数量
  url: `/shopping-cart/modifyNumber`,
  method: "post",
  data
})
const  editCart= (data) => Request({ //修改某条购物车选中状态
  url: `/shopping-cart/select`,
  method: "post",
  data
})

const updateUserApi = (data) => Request({  //更新用户接口
  url: `/user/modify`,
  method: 'POST',
  data
})

const getUserDetailApi = (token) => Request({  //获取用户详情
  url: `/user/detail`,
  data: {token}
})

const checkTokenApi = (token) => Request ({
  url:`/user/check-token`,
  method: 'GET',
  data: {token}
})


export{
  Banner, shopData, infoNoticeApi, goodsListApi, shopList, shopList1, detail, 
  favGoodsCheck, addGoodsCheck, delGoodsCheck, cartList,
  addCart, emptyCart, removeCart, editNum ,editCart ,updateUserApi,getUserDetailApi,
  checkTokenApi
}

